/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package regras;

import Interfaces.CheckerRule;

/**
 *
 * @author Tainá, Ana Luiza e Amanda
 */
public class RuleConsecutiveNumber02 implements CheckerRule{
    private String password;
    public RuleConsecutiveNumber02(String password) {
        this.password = password;
    }
    
    @Override
    public int rule(){
        int consecutiveNumber =0;
        int total = 0;
        char[] pwd = password.replaceAll("\\s+", "").toCharArray(); 
        for (int i = 0; i < pwd.length-1; i++) { 
            if (Character.isDigit(pwd[i]) && Character.isDigit(pwd[i+1]))
                   consecutiveNumber++;
        }
        if (consecutiveNumber>0)
            total -= consecutiveNumber * 2;
        
        return total;
    }
}
